# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'jcw.ui'
#
# Created: Fri Apr 05 23:16:39 2013
#      by: PyQt4 UI code generator 4.10
#
# WARNING! All changes made in this file will be lost!
import xml.etree.ElementTree as ET
from PyQt4 import QtCore, QtGui
from ui_check   import Ui_Check
from checking import load_xml_file
try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s

try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)

class Ui_jcw(object):
    def setupUi(self, jcw):
        jcw.setObjectName(_fromUtf8("jcw"))
        jcw.resize(823, 489)
        jcw.setStyleSheet(_fromUtf8("background-color: rgb(250, 250, 250);"))
        self.horizontalLayout = QtGui.QHBoxLayout(jcw)
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        self.stackedWidget = QtGui.QStackedWidget(jcw)
        self.stackedWidget.setObjectName(_fromUtf8("stackedWidget"))
        self.checkindex = QtGui.QWidget()
        self.checkindex.setObjectName(_fromUtf8("checkindex"))
        self.stackedWidget.addWidget(self.checkindex)
        self.horizontalLayout_2 = QtGui.QHBoxLayout(self.checkindex)
        self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
        spacerItem = QtGui.QSpacerItem(27, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_2.addItem(spacerItem)
        self.mainindex = QtGui.QWidget(self.checkindex)
        self.mainindex.setMinimumSize(QtCore.QSize(500, 0))
        self.mainindex.setObjectName(_fromUtf8("mainindex"))
        self.checkbln = QtGui.QPushButton(self.mainindex)
        self.checkbln.setGeometry(QtCore.QRect(170, 310, 181, 61))
        self.checkbln.setStyleSheet(_fromUtf8("background-image: url(:/skin/img/skin/skin02.jpg);\n"
"font: 100 18pt \"微软雅黑\";\n"
"color: rgb(255, 255, 255);"))
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/jc/img/jc/Fault_fine.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.checkbln.setIcon(icon)
        self.checkbln.setIconSize(QtCore.QSize(100, 100))
        self.checkbln.setFlat(True)
        self.checkbln.setObjectName(_fromUtf8("checkbln"))
        self.qlbl = QtGui.QLabel(self.mainindex)
        self.qlbl.setGeometry(QtCore.QRect(200, 160, 261, 61))
        self.qlbl.setStyleSheet(_fromUtf8("font: 75 12pt \"微软雅黑\";"))
        self.qlbl.setObjectName(_fromUtf8("qlbl"))
        self.splitter = QtGui.QSplitter(self.mainindex)
        self.splitter.setGeometry(QtCore.QRect(0, 30, 404, 118))
        self.splitter.setOrientation(QtCore.Qt.Horizontal)
        self.splitter.setObjectName(_fromUtf8("splitter"))
        self.checkimglbl = QtGui.QLabel(self.splitter)
        self.checkimglbl.setText(_fromUtf8(""))
        self.checkimglbl.setPixmap(QtGui.QPixmap(_fromUtf8(":/jc/img/jc/jsj90.png")))
        self.checkimglbl.setObjectName(_fromUtf8("checkimglbl"))
        self.checkheadlbl = QtGui.QLabel(self.splitter)
        self.checkheadlbl.setStyleSheet(_fromUtf8("font: 75 16pt \"Aharoni\";\n"
"color: rgb(0, 170, 0);"))
        self.checkheadlbl.setObjectName(_fromUtf8("checkheadlbl"))
        self.horizontalLayout_2.addWidget(self.mainindex)
        spacerItem1 = QtGui.QSpacerItem(27, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_2.addItem(spacerItem1)
        self.checkjgw = QtGui.QWidget()
        self.checkingui=Ui_Check()
        self.checkingui.setupUi(self.checkjgw)
        self.checkjgw.setObjectName(_fromUtf8("checkw"))
        
        self.stackedWidget.addWidget(self.checkjgw)
        self.horizontalLayout.addWidget(self.stackedWidget)
        #self.stackedWidget.setCurrentWidget(self.checkindex)
        
        self.line = QtGui.QFrame(jcw)
        self.line.setFrameShape(QtGui.QFrame.VLine)
        self.line.setFrameShadow(QtGui.QFrame.Sunken)
        self.line.setObjectName(_fromUtf8("line"))
        self.horizontalLayout.addWidget(self.line)
        self.rightbar = QtGui.QWidget(jcw)
        self.rightbar.setMinimumSize(QtCore.QSize(200, 0))
        self.rightbar.setMaximumSize(QtCore.QSize(200, 16777215))
        self.rightbar.setObjectName(_fromUtf8("rightbar"))
        self.addsledt = QtGui.QLineEdit(self.rightbar)
        self.addsledt.setGeometry(QtCore.QRect(0, 10, 151, 21))
        self.addsledt.setObjectName(_fromUtf8("addsledt"))
        self.connbtn = QtGui.QPushButton(self.rightbar)
        self.connbtn.setGeometry(QtCore.QRect(150, 10, 40, 21))
        self.connbtn.setStyleSheet(_fromUtf8("font: 75 9pt \"微软雅黑\";"))
        self.connbtn.setObjectName(_fromUtf8("connbtn"))
        self.linkinfo = QtGui.QLabel(self.rightbar)
        self.linkinfo.setGeometry(QtCore.QRect(10, 40, 181, 21))
        self.linkinfo.setObjectName(_fromUtf8("linkinfo"))
        self.line_2 = QtGui.QFrame(self.rightbar)
        self.line_2.setGeometry(QtCore.QRect(10, 60, 171, 16))
        self.line_2.setFrameShape(QtGui.QFrame.HLine)
        self.line_2.setFrameShadow(QtGui.QFrame.Sunken)
        self.line_2.setObjectName(_fromUtf8("line_2"))
        self.label_3 = QtGui.QLabel(self.rightbar)
        self.label_3.setGeometry(QtCore.QRect(10, 80, 51, 16))
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.yybb = QtGui.QLabel(self.rightbar)
        self.yybb.setGeometry(QtCore.QRect(80, 80, 111, 16))
        self.yybb.setObjectName(_fromUtf8("yybb"))
        self.yyip = QtGui.QLabel(self.rightbar)
        self.yyip.setGeometry(QtCore.QRect(80, 110, 111, 16))
        self.yyip.setObjectName(_fromUtf8("yyip"))
        self.label_6 = QtGui.QLabel(self.rightbar)
        self.label_6.setGeometry(QtCore.QRect(10, 110, 61, 16))
        self.label_6.setObjectName(_fromUtf8("label_6"))
        self.yywz = QtGui.QLabel(self.rightbar)
        self.yywz.setGeometry(QtCore.QRect(80, 140, 111, 16))
        self.yywz.setObjectName(_fromUtf8("yywz"))
        self.label_8 = QtGui.QLabel(self.rightbar)
        self.label_8.setGeometry(QtCore.QRect(10, 140, 61, 16))
        self.label_8.setObjectName(_fromUtf8("label_8"))
        self.yycpu = QtGui.QLabel(self.rightbar)
        self.yycpu.setGeometry(QtCore.QRect(80, 170, 111, 16))
        self.yycpu.setObjectName(_fromUtf8("yycpu"))
        self.label_10 = QtGui.QLabel(self.rightbar)
        self.label_10.setGeometry(QtCore.QRect(10, 170, 61, 16))
        self.label_10.setObjectName(_fromUtf8("label_10"))
        self.label_11 = QtGui.QLabel(self.rightbar)
        self.label_11.setGeometry(QtCore.QRect(10, 200, 61, 16))
        self.label_11.setObjectName(_fromUtf8("label_11"))
        self.yync = QtGui.QLabel(self.rightbar)
        self.yync.setGeometry(QtCore.QRect(80, 200, 111, 16))
        self.yync.setObjectName(_fromUtf8("yync"))
        self.dbslm = QtGui.QLabel(self.rightbar)
        self.dbslm.setGeometry(QtCore.QRect(80, 330, 111, 16))
        self.dbslm.setObjectName(_fromUtf8("dbslm"))
        self.dbbb = QtGui.QLabel(self.rightbar)
        self.dbbb.setGeometry(QtCore.QRect(80, 270, 111, 16))
        self.dbbb.setObjectName(_fromUtf8("dbbb"))
        self.label_15 = QtGui.QLabel(self.rightbar)
        self.label_15.setGeometry(QtCore.QRect(10, 360, 61, 16))
        self.label_15.setObjectName(_fromUtf8("label_15"))
        self.label_16 = QtGui.QLabel(self.rightbar)
        self.label_16.setGeometry(QtCore.QRect(10, 390, 61, 16))
        self.label_16.setObjectName(_fromUtf8("label_16"))
        self.dbip = QtGui.QLabel(self.rightbar)
        self.dbip.setGeometry(QtCore.QRect(80, 300, 111, 16))
        self.dbip.setObjectName(_fromUtf8("dbip"))
        self.label_18 = QtGui.QLabel(self.rightbar)
        self.label_18.setGeometry(QtCore.QRect(10, 330, 61, 16))
        self.label_18.setObjectName(_fromUtf8("label_18"))
        self.linkinfo_2 = QtGui.QLabel(self.rightbar)
        self.linkinfo_2.setGeometry(QtCore.QRect(10, 230, 181, 21))
        self.linkinfo_2.setObjectName(_fromUtf8("linkinfo_2"))
        self.dbyhm = QtGui.QLabel(self.rightbar)
        self.dbyhm.setGeometry(QtCore.QRect(80, 360, 111, 16))
        self.dbyhm.setObjectName(_fromUtf8("dbyhm"))
        self.line_3 = QtGui.QFrame(self.rightbar)
        self.line_3.setGeometry(QtCore.QRect(10, 250, 171, 16))
        self.line_3.setFrameShape(QtGui.QFrame.HLine)
        self.line_3.setFrameShadow(QtGui.QFrame.Sunken)
        self.line_3.setObjectName(_fromUtf8("line_3"))
        self.label_20 = QtGui.QLabel(self.rightbar)
        self.label_20.setGeometry(QtCore.QRect(10, 270, 51, 16))
        self.label_20.setObjectName(_fromUtf8("label_20"))
        self.label_21 = QtGui.QLabel(self.rightbar)
        self.label_21.setGeometry(QtCore.QRect(10, 300, 61, 16))
        self.label_21.setObjectName(_fromUtf8("label_21"))
        self.dbljs = QtGui.QLabel(self.rightbar)
        self.dbljs.setGeometry(QtCore.QRect(80, 390, 111, 16))
        self.dbljs.setObjectName(_fromUtf8("dbljs"))
        self.horizontalLayout.addWidget(self.rightbar)

        self.retranslateUi(jcw)
        self.stackedWidget.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(jcw)

    def retranslateUi(self, jcw):
        jcw.setWindowTitle(_translate("jcw", "Form", None))
        self.checkbln.setText(_translate("jcw", "立即体检", None))
        self.qlbl.setText(_translate("jcw", "共发现X项问题", None))
        self.checkheadlbl.setText(_translate("jcw", "上次体检结果：安全", None))
        self.addsledt.setText(_translate("jcw", "http://", None))
        self.connbtn.setText(_translate("jcw", "连接", None))
        self.linkinfo.setText(_translate("jcw", "应用服务器信息：", None))
        self.label_3.setText(_translate("jcw", "版本：", None))
        self.yybb.setText(_translate("jcw", "weblogic10.3", None))
        self.yyip.setText(_translate("jcw", "10.11.10.11", None))
        self.label_6.setText(_translate("jcw", "IP地址：", None))
        self.yywz.setText(_translate("jcw", "bea/", None))
        self.label_8.setText(_translate("jcw", "位置：", None))
        self.yycpu.setText(_translate("jcw", "INTEL XEN 2.8G", None))
        self.label_10.setText(_translate("jcw", "CPU：", None))
        self.label_11.setText(_translate("jcw", "内存：", None))
        self.yync.setText(_translate("jcw", "8G", None))
        self.dbslm.setText(_translate("jcw", "ora", None))
        self.dbbb.setText(_translate("jcw", "oracle 10204", None))
        self.label_15.setText(_translate("jcw", "用户名：", None))
        self.label_16.setText(_translate("jcw", "连接数：", None))
        self.dbip.setText(_translate("jcw", "10.11.10.11", None))
        self.label_18.setText(_translate("jcw", "实例名：", None))
        self.linkinfo_2.setText(_translate("jcw", "数据库服务器信息：", None))
        self.dbyhm.setText(_translate("jcw", "ufgov", None))
        self.label_20.setText(_translate("jcw", "版本：", None))
        self.label_21.setText(_translate("jcw", "IP地址：", None))
        self.dbljs.setText(_translate("jcw", "20", None))
        QtCore.QObject.connect(self.checkbln,QtCore.SIGNAL(_fromUtf8("clicked()")), self.shangestackedWidget)
    def shangestackedWidget(self):
        self.stackedWidget.setCurrentWidget(self.checkjgw)
        self.load_rule('check/gl.xml')
    
    def load_rule(self,fileName):
        root = ET.parse(fileName).getroot()
        module=root.find('module').text
        #获取所有list节点
        all_rule = root.findall('rule')
        
        #遍历list节点的子元素
        for rule in all_rule:
            item = QtGui.QTreeWidgetItem()
            name = rule.find('name').text
            type = rule.find('type').text
            warninglevel = rule.find('warninglevel').text
            massage = rule.find('massage').text
            sql = rule.find('sql').text
            self.checkingui.messagelbl.setText(name)
            checkrsItem=self.__check(type,sql)
            if  checkrsItem:
                item.setText(0,name+warninglevel)#检查项            
                item.setIcon(0,self.checkingui.fineicon)
                item.setIcon(1,self.checkingui.warningicon)
                item.addChildren(checkrsItem)
                self.checkingui.treeWidget.topLevelItem(0).addChild(item)#.addChilds(checkrsItem)
                print item.childCount() 
            else:
                item.setText(0,name)#检查项          
                item.setIcon(0,self.checkingui.fineicon)
                item.setIcon(1,self.checkingui.warningicon)
                self.checkingui.treeWidget.topLevelItem(1).addChild(item)
            #返回list 使用dict
            print name,type,warninglevel,massage,sql
    def __check(self,type,sql):
        '''
        retrun Item list
        '''
        itemlist=[]
        sql='1234567890ssss'
        for i in sql:            
            item = QtGui.QTreeWidgetItem()
            item.setText(0,i)
            item.setIcon(0,self.checkingui.fineicon)
            item.setIcon(1,self.checkingui.warningicon)
            itemlist.append(item)        
        return itemlist
                
import qrc_rc
